from presenter import basepresenter

class AdminProfilePresenter(basepresenter.BasePresenter):

    def respondToGet(self):
        #get the articles
        profiles = self.userprofiletask.getAll()
        self.template_values['profiles'] = profiles

        # set up the page title
        page_title = self.sitetitle + ' - User Profile Admin'
        self.template_values['page_title'] = page_title

        #get the view to draw the page
        self.view.showGetResponse(self.template_values)

    def respondToPost(self):
        destination = '/adminprofile'
        if (self.request.get('action') == "Disable Profile"):
            oldprofile = self.userprofiletask.getByKey(self.request.get('profilekey'))
            self.userprofiletask.disable(oldprofile)

        if (self.request.get('action') == "Enable Profile"):
            oldprofile = self.userprofiletask.getByKey(self.request.get('profilekey'))
            self.userprofiletask.enable(oldprofile)

        #get the view to draw the page
        self.view.showPostResponse(destination)